//
//  ForgetPasswordViewController.m
//  HuLaQuan
//
//  Created by hok on 1/14/16.
//  Copyright © 2016 Jianghao. All rights reserved.
//

#import "ForgetPasswordViewController.h"

#import "YuVerifyButton.h"

#import "YuLoginInputInfoField.h"


//jump to controller
#import "ForgetPWFirstInputPasswordController.h"

#import "ForgetUserPasswordEngine.h"

@interface ForgetPasswordViewController()
{
    NSInteger count;
}
@property(strong,nonatomic)NSTimer *timerCount;
@property (weak, nonatomic) IBOutlet YuVerifyButton *verifyCodeButton;

@property(nonatomic,strong)ForgetUserPasswordEngine *engine;

@end

@implementation ForgetPasswordViewController

- (ForgetUserPasswordEngine *)engine
{
    if (!_engine) {
        _engine = [[ForgetUserPasswordEngine alloc] init];
    }
    return _engine;
}
// Fot test
//- (IBAction)tapNextButton:(id)sender {
//    NSLog(@"%@",self.userInfo);
//    [self performSegueWithIdentifier:@"ShowFirstInputPaswordFromForgetPassword" sender:self];
//}
- (void)verifySMSFinish:(id)message
{
    [self.userInfo addEntriesFromDictionary:message];
    [self performSegueWithIdentifier:@"ShowFirstInputPaswordFromForgetPassword" sender:self];
}


#pragma mark - Controller Life Cycle
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    
    self.smsVerifyEngine.smsType = SMSForgetUserPW;
    //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkVerifyCodeFinish:) name:@"CheckVerifyCodeFinish" object:nil];
    

}


- (void)viewWillDisappear:(BOOL)animated
{

   
    [super viewWillDisappear:YES];
    
    
}

#pragma mark - Navigation

- (void)goBackAction
{
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
    UIAlertController *x = [UIAlertController alertWithTitle:@"提示" andMessage:@"是否放弃重置登录密码" andBlock:^(UIAlertAction *action ) {
        if ([action.title isEqualToString:@"好的"]) {
            [self.navigationController popToRootViewControllerAnimated:YES];
           
        }
        
    }  type:@"confirmAndCancel"];
    [self presentViewController:x animated:YES completion:nil];
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([[segue identifier] isEqualToString:@"ShowFirstInputPaswordFromForgetPassword"]) {
        ForgetPWFirstInputPasswordController *controller = (ForgetPWFirstInputPasswordController*) [segue destinationViewController];
        controller.type = UserPassword;
        controller.titleOfNav = kSetUserPasswordTitle;
        controller.titleOfPassword = kSetUserPasswordHint;
        controller.passwordAndInfos = self.userInfo;
        NSLog(@"%@",controller.passwordAndInfos);
    }
}

@end
